<%@ page import="com.wuming.house.security.SecurityHander" %>
<%--
  Created by IntelliJ IDEA.
  User: zengyao
  Date: 2018/6/30
  Time: 14:52
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<html>
<head>
    <meta charset="utf-8">
    <title>修改密码</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="${allServerPath}static/layui/layui/css/layui.css" media="all">
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body style="background-color: #f0f2f5;">
<div style="padding: 15px;margin: 15px;background-color: #fff;">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>修改密码</legend>
    </fieldset>
    <form class="layui-form" id="editUser">
        <div class="layui-row">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">旧密码</label>

                    <div class="layui-input-inline">
                        <input name="oldPassword" class="layui-input" type="password" autocomplete="off"
                               placeholder="请输入旧密码"
                               value="">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">新密码</label>

                    <div class="layui-input-inline">
                        <input name="password" class="layui-input" type="password" autocomplete="off"
                               placeholder="请输入密码"
                               value="">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">确认密码</label>

                    <div class="layui-input-inline">
                        <input name="rePassword" class="layui-input" type="password" autocomplete="off"
                               placeholder="请输入确认密码"
                               value="">
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-row">
            <button class="layui-btn layui-btn-normal" type="button" name="btnSave" id="saveUser">保存</button>
        </div>
        <input type="hidden" name="id" value="${member['id']}"/>
    </form>
</div>


<%--<div class="layui-form-item">--%>
<%--<div class="layui-inline">--%>
<%--<label class="layui-form-label">122用戶名</label>--%>

<%--<div class="layui-input-inline">--%>
<%--<input name="userName122" class="layui-input" type="tel" autocomplete="off" placeholder="122用户名"--%>
<%--value="${member['userName122']}">--%>
<%--</div>--%>
<%--</div>--%>
<%--</div>--%>

<%--<div class="layui-form-item">--%>
<%--<div class="layui-inline">--%>
<%--<label class="layui-form-label">122密码</label>--%>

<%--<div class="layui-input-inline">--%>
<%--<input name="password122" class="layui-input" type="password" autocomplete="off" placeholder="122密码"--%>
<%--value="${member['password122']}">--%>
<%--</div>--%>
<%--</div>--%>
<%--</div>--%>


<script src="${allServerPath}static/layui/layui/layui.js"></script>
<script>
    layui.use(['form', 'jquery'], function () {
        var form = layui.form
                , layer = layui.layer
                , $ = layui.jquery;


        $("#saveUser").click(function () {
            var password = $("input[name='password']").val();
            var rePassword = $("input[name='rePassword']").val();
            if (password != rePassword) {
                layer.msg("密码和确认密码不同.");
                return false;
            }
            $.ajax({
                type: "post",
                url: "${allServerPath}/web/member/modifyPass.htmls",
                //data: $('#editUser').serialize(),// 你的formid
                data: {
                    memberId: <%=SecurityHander.getCurrentUserId()%>,
                    oldPassword: $("input[name='oldPassword']").val(),
                    password: $("input[name='password']").val()
                },
                dataType: "JSON",
                success: function (data) {
                    if (data.success) {
                        layer.msg("密码修改成功.");
                    } else if (data.message == ("与旧密码重复")) {
                        layer.msg("请不要与旧密码重复");
                    } else if (data.message == ("旧密码验证错误")) {
                        layer.msg("旧密码填写错误");
                    } else {
                        layer.msg("密码修改失败.");
                    }
                },
                error: function (msg) {
                    layer.msg("密码修改失败.");
                }
            });
        });
    });
</script>
</body>
</html>
